package com.ddmmo.exhibition.localBOSS.project.controller;

import com.ddmmo.exhibition.common.annotation.WebLog;
import com.ddmmo.exhibition.common.entity.Result;
import com.ddmmo.exhibition.localBOSS.project.entity.po.TbProjectDataPO;
import com.ddmmo.exhibition.localBOSS.project.service.ProjectDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 项目数据详情 - Controller
 * </p>
 *
 * @author JiangYiji
 * @since 2024/10/30
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/projectData")
@Api(tags = "项目数据详情-Controller")
public class ProjectDataController {

    @Autowired
    private ProjectDataService projectDataService;

    @WebLog
    @GetMapping("/selectProjectDataByClassifyId/{classifyId}")
    @ApiOperation(value = "根据分类ID查询数据详情")
    public Result<List<TbProjectDataPO>> selectProjectClassifyById(@PathVariable String classifyId) {
        List<TbProjectDataPO> projectClassify = projectDataService.selectProjectDataById(classifyId);
        return Result.success(projectClassify);
    }

    @WebLog
    @PostMapping ("/addProjectData")
    @ApiOperation(value = "批量添加项目数据详情")
    public Result addProjectData(@RequestBody List<TbProjectDataPO> projectDataPOs) {
        Result result = projectDataService.addProjectData(projectDataPOs);
        return result;
    }

    @WebLog
    @GetMapping("/deleteProjectDataById/{id}")
    @ApiOperation(value = "根据ID删除项目数据详情")
    public Result deleteProjectDataById(@PathVariable String id) {
        Result result = projectDataService.deleteProjectDataById(id);
        return result;
    }

}
